package com.atguigu.easyexcel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;

import java.util.Map;

/**
 * excel侦听器
 *
 * @author MasterX
 * @date 2022/02/03
 */
public class ExcelListener extends AnalysisEventListener<UserData> {
    //读取表头信息
    @Override public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        System.out.println("表头信息:" + headMap);
    }

    //一行一行读取excel内容，从第二行开始读取
    @Override public void invoke(UserData userData, AnalysisContext analysisContext) {
        System.out.println(userData);
    }

    //读取之后再执行
    @Override public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        System.out.println("读取后操作");
    }
}
